
import MUtil from 'util/mm.jsx'
import $ from 'jquery'

const _Ajax=new MUtil()

class User{
  login (loginInfo) {
    return _Ajax.request({
      type: 'post',
      url: '/manage/user/login.do',
      data: loginInfo
    })
  }
  //检查登陆接口的数据
  checkLogin(loginInfo) {
    let username = $.trim(loginInfo.username)
    let password = $.trim(loginInfo.password)
    if(typeof username !=='string' || username.length === 0){
      return {
        status: false,
        msg: '用户名不能为空'
      }
    }
    if(typeof password !=='string' || password.length === 0){
      return {
        status: false,
        msg: '密码不能为空'
      }
    }
    return {
      status: true,
      msg: '验证通过'
    }
  }
  //退出登录
  logout() {
    return _Ajax.request({
      type: 'post',
      url: '/user/logout.do'
    })
  } 
} 

export default User